MF> I don't fully understand the problem with using Dispose with Release.
MF> For example, with the following code blurb (written online):
MF> VAR
MF> P1 : POINTER;
MF> P2 : POINTER;
MF> P3 : POINTER;
MF> Ptr4Heap : POINTER;
MF> BEGIN
MF> Mark(Ptr4Heap);
MF> New(P1);
MF> New(P2);
MF> New(P3);
MF> Dispose(P2);
MF> Release(Ptr4Heap);
MF> END.
MF> What is wrong with using it in this method? It seems to me that all
MF> that would happen is that P1 and P3 would effectively be disposed,
MF> while P2 has already been disposed of.
There is nothing wrong in using the above method as long as you fully understandthe possible ramifications in a real program. When you use release the freelistif there is one, is lost. That means that any free heap space amongst heap
data
that was present BEFORE the mark procedure was used is lost. Perhaps an
example is the easiest way to explain -
begin
new(p1);
new(p2);
new(p3);
dispose(p2);
mark(ptr4heap);
new(p4);
new(p5);
release(ptr4heap);
Now the free space that was formerly used by p2^ is lost.
TeeCee
* Origin: The Pilbara's Pascal Centre (+61 91 732569) (3:690/644)